/*
 * Copyright (c) Lin Zhe <lene13@gmail.com>
 * All rights reserved.
 *
 * This file is part of the RabbitOS.  The RabbitOS is free software, also known
 * as "open source;" you can redistribute it and/or modify it under the terms
 * of the GNU General Public License (GPL), version 2, as published by the Free
 * Software Foundation (FSF).  To explore alternate licensing terms, contact
 * the Rabbit OS team.
 * 
 * The RabbitOS is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GPL for more details.  You should have
 * received a copy of the GPL along with the RabbitOS; see the file COPYING. If
 * not, write to the FSF, 59 Temple Place #330, Boston, MA 02111-1307, USA.
 *
 */
/*
 * ISO C99 Standard 7.4 character handling <ctype.h>
 * And some extensive functions.
 * 05-May-08
 */

#ifndef _CTYPE_H
#define _CTYPE_H

#define isspace(x) (x==' '||x=='\f'||x=='\n'||x=='\r'||x=='\t'||x=='\v')
#define islower(x) (x>='a'&&x<='z')
#define isupper(x) (x>='A'&&x<='Z')
#define isalpha(x) (islower(x)|isupper(x))
#define isdigit(x) (x>='0'&&x<='9')
#define isalnum(x) (isalpha(x)|isdigit(x))
#define isxdigit(x) (isdigit(x)||(x>='a'&&x<='f')||(x>='A'&&x<='F'))
#define isascii(x) (x>=0&&x<128)

//Returns true if c is a punctuation character.
//This means any printing character that is NOT alphanumeric OR a space character.
#define ispunct(x) (1-isalnum(x)-isspace(x))

//Returns true if c is a graphic character;
//that is, a character that has a glyph associated with it.
//The whitespace characters are NOT considered graphic.
#define isgraph(x) (x>=0x21&&x<=7E&&x!=' ')

//Returns true if c is a printing character.
//Printing characters include all the graphic characters, plus the space (' ') character.#define isprint(x) (isgraph(x)|x==' ')

//Returns true if c is a control character
//that is, a character that is not a printing character
#define iscntrl(x) ((1-isprint(x))&isascii(x))
#define tolower(x) (isupper(x)?(x+'a'-'A'):x)
#define toupper(x) (islower(x)?(x+'A'-'a'):x)

#endif							//_CTYPE_H
